package com.xiang.publicdemo.module1.service.impl;

import com.xiang.publicdemo.module1.entity.AbstractEntity;
import com.xiang.publicdemo.module1.repository.IAbstractRepository;
import com.xiang.publicdemo.module1.service.IAbstractService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Slf4j
@Transactional(readOnly = true)
public abstract class AbstractServiceImpl<E extends AbstractEntity> implements IAbstractService<E> {
    @Autowired
    protected IAbstractRepository<E> repository;

    @Override
    @Transactional
    public E add(E e) {
        return repository.add(e);
    }

    @Override
    @Transactional
    public int delete(String id) {
        return repository.delete(id);
    }

    @Override
    @Transactional
    public E update(E e) {
        return repository.update(e);
    }

    @Override
    public E findById(String id) {
        return repository.findById(id);
    }

    @Override
    public E findOne(E e) {
        return repository.findOne(e);
    }

    @Override
    public List<E> find(E e) {
        return repository.find(e);
    }
}
